<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jquery-3.6.0.min.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        ul {
            list-style: none;

        }

        .box {
            width: 1226px;
            height: 460px;
            margin: 50px auto 0;
            position: relative;
            overflow: hidden;
            position: relative;
        }

        .navigation {
            width: 100px;
            height: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: absolute;
            left: 1100px;
            top: 420px;
            z-index: 6;
        }

        .navigation>li {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            border: 2px solid rgb(85, 204, 219);
        }

        .active {
            background-color: rgb(114, 216, 93);
        }

        .picture {
            width: max-content;
            height: 460px;
            /* overflow: hidden; */
            position: absolute;
            left: 0;
        }

        .picture li {
            width: 1226px;
            height: 460px;
            float: left;
        }

        .picture img {
            width: 100%;
            height: 100%;
        }

        /* .picture .show {
            display: block;
        } */
    </style>
</head>

<body>
    <div class="box">
        <ul class="navigation">
            <li class="active"></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
        <ul class="picture">
            <li class="show"><img
                    src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/d2082a18632ef1f7aa06d90b39a8c06b.jpg?w=2452&h=920"
                    alt=""></li>
            <li><img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/6fae8cbea12505f89b350c48d407441a.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                    alt=""></li>
            <li><img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/918820682e4a490221cfd92b24c14b86.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                    alt=""></li>
            <li><img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/c568030fd3637ac46f753a46bc244c9f.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                    alt=""></li>
            <li><img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/356e61ba0695e6b9d97a7ea35168e75e.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                    alt=""></li>
            <li><img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/d2082a18632ef1f7aa06d90b39a8c06b.jpg?w=2452&h=920"
                    alt=""></li>
        </ul>
    </div>
</body>
<script>

    var swiperWidth = $(".box").width();
    // console.log(swiperWidth);
    //  // 一张图片的宽度

    var index = 0;  //全局变量 记录轮播的下标

    /* $(".navigation li").click(function () {
        console.log(this);
        index = $(this).index();
        console.log(index);
        $(this).addClass("active").siblings().removeClass("active")
    }) */

    var timer = setInterval(function () {
        index++;
        var activeIndex = index >=$(".navigation li").length ? 0 : index
        console.log(index,activeIndex);

        $(".navigation li").eq(activeIndex).addClass("active").siblings().removeClass("active")
        $(".picture").animate({ left: -swiperWidth * index }, "normal", function () {
            // console.log("本次运动结束:", index);
            
            if (index >= $(".navigation li").length){  // 第六张下标 5
                $(".picture").css({left :0})
                index = 0;
            }
        })

    }, 3000)


</script>

</html>